package com.yyi.springcloud.controller;


import com.yyi.springcloud.entities.CoordonateConfigModel;
import com.yyi.springcloud.entities.CoordonateInfoVo;
import com.yyi.springcloud.entities.SensorConfigVo;
import com.yyi.springcloud.service.Local_CoordonateConfigService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/mysqlapi/CoordonateConfig")
public class Mysql_CoordonateConfigController {
	@Resource
	private Local_CoordonateConfigService coordonateConfigService;

    //根据台位号获取传感器的名称(配置信息专用)
	//http://localhost:8080/bxxs/mysqlapi/CoordonateConfig/getCoordonateConfigName
	@ResponseBody
	@RequestMapping(value = "/getCoordonateConfigName", method = RequestMethod.GET)
	public List<CoordonateConfigModel> getInfo(Integer testunitno) {
		testunitno=3;
		CoordonateConfigModel coordonateConfigModel=new CoordonateConfigModel();
		coordonateConfigModel.setTestunitno(null==testunitno?0:testunitno);
		return coordonateConfigService.getCoordonateConfigByCondition(coordonateConfigModel);
	}

	//根据VERSIONNO查询相关信息(独立接口专用)
	//http://localhost:8080/bxxs/mysqlapi/CoordonateConfig/getCoordinateInfo
	@ResponseBody
	@RequestMapping(value = "/getCoordinateInfo", method = RequestMethod.GET)
	public List<CoordonateInfoVo> getCoordinateInfo(String labcode, String versionNo) {
		if(StringUtils.isEmpty(versionNo)){
			versionNo="";
		}
		return coordonateConfigService.selectCoordinateInfo(labcode, versionNo);
	}

	//根据LABCODE查询相关信息(独立接口专用)
	//http://localhost:8080/bxxs/mysqlapi/CoordonateConfig/getSensorConfigInfo
	@ResponseBody
	@RequestMapping(value = "/getSensorConfigInfo", method = RequestMethod.GET)
	public List<SensorConfigVo> getSensorConfigInfo(String labcode) {
		if(StringUtils.isEmpty(labcode)){
			labcode="";
		}
		return coordonateConfigService.selectSensorConfigInfo(labcode);
	}
}
